package com.sina.weibo;

import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.AsyncTask.Status;
import android.os.Bundle;
import android.widget.Toast;
import com.sina.weibo.models.MBlog;
import com.sina.weibo.models.User;
import java.util.List;

public class LoadingActivity extends ScreenOrientationBaseActivity
{
  private static final int DIALOG_PROGRESS_LOADING = 100;
  private LoadWeiboTask myLoadWeiboTask;

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    Intent localIntent1 = getIntent();
    String str1 = localIntent1.getScheme();
    Uri localUri;
    String str2;
    if ((str1 != null) && (str1.equals("sinaweibo")) && (localIntent1.getData() != null))
    {
      localUri = localIntent1.getData();
      str2 = localUri.getHost();
      if (Utils.getLoginStatus())
        break label87;
      Intent localIntent2 = new Intent();
      Context localContext1 = getApplicationContext();
      Intent localIntent3 = localIntent2.setClass(localContext1, MainTabActivity.class);
      startActivity(localIntent3);
    }
    while (true)
    {
      return;
      label87: if (str2.equals("reg"))
      {
        Intent localIntent4 = new Intent();
        Context localContext2 = getApplicationContext();
        Intent localIntent5 = localIntent4.setClass(localContext2, SwitchUser.class);
        startActivity(localIntent5);
        continue;
      }
      if (str2.equals("user"))
      {
        List localList1 = localUri.getPathSegments();
        String str3 = (String)localList1.get(0);
        String str4 = (String)localList1.get(1);
        Intent localIntent6 = new Intent();
        Context localContext3 = getApplicationContext();
        Intent localIntent7 = localIntent6.setClass(localContext3, UserInfoActivity2.class).putExtra("uid", str3).putExtra("nick", str4);
        String str5 = StaticInfo.mUser.uid;
        Intent localIntent8 = localIntent7.putExtra("myuid", str5).putExtra("vip", 0);
        startActivity(localIntent8);
        continue;
      }
      if (str2.equals("userblog"))
      {
        List localList2 = localUri.getPathSegments();
        String str6 = (String)localList2.get(0);
        String str7 = (String)localList2.get(1);
        Intent localIntent9 = new Intent();
        Context localContext4 = getApplicationContext();
        Intent localIntent10 = localIntent9.setClass(localContext4, UserWeiboAttentionFansList.class).putExtra("uid", str6).putExtra("nick", str7).putExtra("mode", 1);
        String str8 = StaticInfo.mUsername;
        Intent localIntent11 = localIntent10.putExtra("username", str8);
        String str9 = StaticInfo.mPassword;
        Intent localIntent12 = localIntent11.putExtra("password", str9);
        startActivity(localIntent12);
        continue;
      }
      if (str2.equals("blog"))
      {
        String str10 = (String)localUri.getPathSegments().get(0);
        LoadWeiboTask localLoadWeiboTask1 = new LoadWeiboTask(null);
        this.myLoadWeiboTask = localLoadWeiboTask1;
        LoadWeiboTask localLoadWeiboTask2 = this.myLoadWeiboTask;
        String[] arrayOfString = new String[1];
        arrayOfString[0] = str10;
        AsyncTask localAsyncTask = localLoadWeiboTask2.execute(arrayOfString);
        continue;
      }
      if (!str2.equals("setting"))
        continue;
      Context localContext5 = getApplicationContext();
      Intent localIntent13 = new Intent(localContext5, SettingsPref.class);
      startActivity(localIntent13);
    }
  }

  protected Dialog onCreateDialog(int paramInt)
  {
    Object localObject = null;
    switch (paramInt)
    {
    default:
    case 100:
    }
    while (true)
    {
      return localObject;
      ProgressDialog localProgressDialog = new ProgressDialog(this);
      String str = getString(2131427422);
      localProgressDialog.setMessage(str);
      localObject = localProgressDialog;
    }
  }

  protected void onDestroy()
  {
    if (this.myLoadWeiboTask != null)
    {
      AsyncTask.Status localStatus1 = this.myLoadWeiboTask.getStatus();
      AsyncTask.Status localStatus2 = AsyncTask.Status.RUNNING;
      if (localStatus1 == localStatus2)
      {
        boolean bool = this.myLoadWeiboTask.cancel(1);
        this.myLoadWeiboTask = null;
      }
    }
    super.onDestroy();
  }

  class LoadWeiboTask extends AsyncTask<String, Void, Boolean>
  {
    private MBlog blog;

    private LoadWeiboTask()
    {
    }

    protected Boolean doInBackground(String[] paramArrayOfString)
    {
      String str = paramArrayOfString[0];
      try
      {
        RPCHelper localRPCHelper = RPCHelper.getInstance(LoadingActivity.this.getApplication());
        User localUser = StaticInfo.mUser;
        Object[] arrayOfObject = localRPCHelper.getSingleMBlog(localUser, str, 240);
        if ((arrayOfObject != null) && (arrayOfObject.length > 0) && (arrayOfObject[1] != 0))
        {
          MBlog localMBlog = (MBlog)arrayOfObject[1];
          this.blog = localMBlog;
          Boolean localBoolean1 = Boolean.valueOf(1);
          localBoolean2 = localBoolean1;
          return localBoolean2;
        }
      }
      catch (RPCHelper.HttpException localHttpException)
      {
        while (true)
          Boolean localBoolean2 = Boolean.valueOf(0);
      }
    }

    protected void onPostExecute(Boolean paramBoolean)
    {
      super.onPostExecute(paramBoolean);
      LoadingActivity.this.dismissDialog(100);
      if (paramBoolean.booleanValue())
      {
        LoadingActivity localLoadingActivity = LoadingActivity.this;
        Intent localIntent1 = new Intent();
        Context localContext = LoadingActivity.this.getApplicationContext();
        Intent localIntent2 = localIntent1.setClass(localContext, DetailWeiboActivity.class);
        MBlog localMBlog = this.blog;
        Intent localIntent3 = localIntent2.putExtra("KEY_MBLOG", localMBlog);
        User localUser = StaticInfo.mUser;
        Intent localIntent4 = localIntent3.putExtra("KEY_MUSR", localUser);
        localLoadingActivity.startActivity(localIntent4);
      }
      while (true)
      {
        return;
        Toast.makeText(LoadingActivity.this, 2131427395, 0).show();
        LoadingActivity.this.finish();
      }
    }

    protected void onPreExecute()
    {
      super.onPreExecute();
      LoadingActivity.this.showDialog(100);
    }
  }
}